#include "spawner.h"
#include "entity/enemy.h"
#include "core/scene.h"
#include "world/effect.h"
#include "entity/player.h"
void spawner::update(float dt){
    if(!target_||!target_->isActive())return;
    timer_+= dt;
    if(timer_ >= interval_){
        timer_ = 0;
        //spawn enemy
        game_.playSound("assets/sound/silly-ghost-sound-242342.mp3");
        for(int i = 0; i < num_; i++){
            auto pos = game_.randomVec2(game_.getCurrentScene()->getCameraPosition(), 
            game_.getCurrentScene()->getCameraPosition() + game_.getScreenSize());
            enemy* ey = enemy::createEnemy(nullptr, pos,target_);
            effect::createEffect(game_.getCurrentScene(),
                "assets/effect/184_3.png", pos,1.0f,ey);
        }
    }
}